# -*- encoding=utf8 -*-
"""
RedFlag-TC000062   暂停中调试美颜
拍摄暂停唤起美化工具栏检查右侧图标数量场景
拍摄暂停后开关美颜场景
拍摄暂停后唤起美颜切换参数场景
"""
__author__ = "ldm"

import sys
import os

# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()

log("--------------------------------拍摄暂停唤起美化工具栏检查右侧图标数量场景--------------------------------------")
"""
进入相机拍摄
点击两次拍摄按钮
点击美化
获取数量
断言
"""
shooter.enter_photograph()
shooter.multiple_dense_clicks(shooting_button, 2, 2)
shooter.click_element(shooting_page_beautify)
quantity_text = shooter.get_child_count(shooting_page_side_function_bar)
shooter.assert_texts_equal(quantity_text, 1, "断言失败，实际数量与预期数量不符合")

log("--------------------------------拍摄暂停后开关美颜场景--------------------------------------")
"""
点击美颜开关
获取文本
断言
点击美颜开关
获取文本
断言
"""
shooter.click_element(beautify_switch)
close_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clip_et_beautify_open_tv"))
shooter.assert_texts_equal(close_text, "美颜关", "断言失败，预期文案与实际文案不符合，美颜功能未关闭")
shooter.click_element(beautify_switch)
close_text = shooter.get_element_text(poco("cn.migu.video.clip.walle:id/clip_et_beautify_open_tv"))
shooter.assert_texts_equal(close_text, "美颜开", "断言失败，预期文案与实际文案不符合，美颜功能未开启")

log("--------------------------------拍摄暂停后唤起美颜切换参数场景--------------------------------------")
"""
点击磨皮
断言
"""
shooter.click_element(beautify_element_dermabrasion)
parameter_text = shooter.get_element_text(beautify_element_exists)
shooter.assert_texts_equal(parameter_text, "50", "断言失败，并未切换到磨皮")
shooter.assert_image_exists(r"tpl1747214277491.png", "断言失败，并未发现目标图片", record_pos=(0.161, 0.779), resolution=(1224, 2700))

# 关闭应用
stop_app(UGC_package_name)